-- vim.g.python_host_prog = '~/py2/bin/python'
-- vim.g.node_host_prog="~/.nvm/versions/node/v14.20.1/bin/node"
--
local bind = require("keymap.bind")
local lsp = require("modules.completion.config")
lsp.nvim_lsp()
lsp.completion()
lsp.vim_vsnip()
-- lsp.nvim_trouble()

local tool = require("modules.tool.config")
if vim.g.use_plugin_telescope then
	tool.telescope()
end

local debug = require("modules.debug.config")
if vim.g.use_dap==1 then
  debug.dap()
end

local dev = require("modules.dev.config")
dev.outline()
dev.comment()
dev.project()
dev.trouble()
dev.document()
require("modules.tabline.config")

local ui = require("modules.ui.config")
ui.statusline()
ui.explorer()

local map_cr = bind.map_cr
local map_cu = bind.map_cu
local map_cmd = bind.map_cmd
local map_args = bind.map_args
-- nnoremap <silent>gr <cmd>lua require('lspsaga.rename').rename()<CR>
local def_map = {
	--["n|gp"] = map_cr("Lspsaga preview_definition"):with_noremap():with_silent(),
	["n|gi"] = map_cmd("<cmd>lua vim.lsp.buf.implementation()<CR>"):with_noremap():with_silent(),
	-- ["n|gr"] = map_cr("References"):with_noremap():with_silent(),
	-- ["n|gr"] = map_cr("Telescope lsp_references"):with_noremap():with_silent(),
	["n|rn"] = map_cr("lua vim.lsp.buf.rename()"):with_noremap():with_silent(),
	["n|gd"] = map_cmd("<cmd>lua vim.lsp.buf.definition()<CR>"):with_noremap():with_silent(),
	["n|<2-LeftMouse>"] = map_cmd("<cmd>lua vim.lsp.buf.definition()<CR>"):with_noremap():with_silent(),
	["n|gD"] = map_cmd("<cmd>lua vim.lsp.buf.declaration()<CR>"):with_noremap():with_silent(),
	--["n|[e"] = map_cr("Lspsaga diagnostic_jump_next"):with_noremap():with_silent(),
	--["n|]e"] = map_cr("Lspsaga diagnostic_jump_prev"):with_noremap():with_silent(),
	["n|[e"] = map_cmd("<cmd>lua vim.diagnostic.goto_next()<CR>"):with_noremap():with_silent(),
	["n|]e"] = map_cmd("<cmd>lua vim.diagnostic.goto_prev()<CR>"):with_noremap():with_silent(),
	--["n|<Leader>a"]      = map_cr('Lspsaga show_line_diagnostics'):with_noremap():with_silent(),
	-- ["n|<Leader>ce"] = map_cr("Diagnostics"):with_noremap():with_silent(),
	["n|<Leader>ca"] = map_cr("lua vim.lsp.buf.code_action()"):with_noremap():with_silent(),
	["n|<Leader>qf"] = map_cr("lua vim.lsp.buf.code_action()"):with_noremap():with_silent(),
	["n|<Leader>cew"] = map_cr("DiagnosticsAll"):with_noremap():with_silent(),
	["n|<Leader>ss"] = map_cmd("<cmd>lua vim.lsp.buf.workspace_symbol()<CR>"):with_noremap():with_silent(),
	["n|<Leader>kk"] = map_cmd("<cmd>lua vim.lsp.buf.signature_help() <CR>"):with_noremap():with_silent(),
	["n|<C-k>"] = map_cmd("<cmd>lua vim.lsp.buf.toggle_float_win() <CR>"):with_noremap():with_silent(),
	["v|<C-k>"] = map_cmd("<cmd>lua vim.lsp.buf.toggle_float_win() <CR>"):with_noremap():with_silent(),
	["i|<C-k>"] = map_cmd("<cmd>lua vim.lsp.buf.toggle_float_win() <CR>"):with_noremap():with_silent(),
	--["n|<Leader>o"] = map_cmd("<cmd>lua vim.lsp.buf.document_symbol()<CR>"):with_noremap():with_silent(),
	["n|<Leader>o"] = map_cmd("<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>"):with_noremap():with_silent(),
	["n|<Leader>cf"] = map_cmd("<cmd>lua vim.lsp.buf.format()<CR>"):with_noremap():with_silent(),
	["v|<Leader>cf"] = map_cmd(":<c-u>lua vim.lsp.buf.format()<CR>"):with_noremap():with_silent(),
  -- ["n|<leader>cc"] = map_cr("lua require('Comment').toggle()"):with_noremap():with_silent(),
	--["n|<Leader>cc"] = map_cmd("<cmd>CommentToggle<CR>"):with_noremap():with_silent(),

	-- ["n|<Leader>fw"] = map_cu("Telescope grep_string"):with_noremap():with_silent(),
	-- ["n|<Leader>fq"] = map_cu("Clap quickfix"):with_noremap():with_silent(),
	-- ["n|cw"] = map_cu("Clap quickfix"):with_noremap():with_silent(),
	["n|<Leader>fr"] = map_cr("Farf"):with_noremap():with_silent(),
	["n|<Leader>fl"] = map_cr("BLines"):with_noremap():with_silent(),
	["n|<Leader>ft"] = map_cr("BTags"):with_noremap():with_silent(),
	["v|<Leader>fr"] = map_cr("Farf"):with_noremap():with_silent(),

	["v|<Leader>i"] = map_cr("SymbolsOutline"):with_noremap():with_silent(),
	["n|<leader>qq"] = map_cr("Bw"):with_noremap():with_silent(),
	["n|<Leader>gf"] = map_cr("GFiles"):with_noremap():with_noremap():with_silent(),
	["n|ss"] = map_cr("lua require('sg.extensions.telescope').fuzzy_search_results()"):with_noremap():with_noremap():with_silent(),
	["n|<Leader>bd"] = map_cr("Bw"):with_noremap():with_noremap():with_silent(),
  ["n|<leader>xf"] = map_cr("NERDTreeFind"):with_noremap():with_noremap():with_silent(),
}
vim.api.nvim_command("command! -nargs=0 ShowT :Telescope treesitter")
bind.nvim_load_mapping(def_map)
